package de.lot.action;

import de.lot.model.Trait;
import java.util.Arrays;
import java.util.List;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;

/**
 * String, representing the whole list of all Traits.
 *
 * @author Stefan Kohler <kohler.stefan@gmail.com>
 */
@Name("traitList")
public class TraitList extends EntityQuery<Trait> {

    private Trait trait = new Trait();
    private static final String[] RESTRICTIONS = {
        "lower(trait.number) like concat(lower(#{traitList.trait.number}),'%')",
        "lower(trait.name) like concat(lower(#{traitList.trait.name}),'%')",
        "lower(trait.failsExpectations) like concat(lower(#{traitList.trait.failsExpectations}),'%')",
        "lower(trait.meetsExpectations) like concat(lower(#{traitList.trait.meetsExpectations}),'%')",
        "lower(trait.exceedsExpectations) like concat(lower(#{traitList.trait.exceedsExpectations}),'%')"};

    @Override
    public String getEjbql() {
        return "select trait from Trait trait";
    }

    @Override
    public List<String> getRestrictions() {
        return Arrays.asList(RESTRICTIONS);
    }

    public Trait getTrait() {
        return trait;
    }
}
